package com.zyd.xtgl.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.zyd.common.GenericHibernateDao;
import com.zyd.xtgl.dao.IAdmDeptDAO;
import com.zyd.xtgl.domain.vo.TbAdmDept;

@Repository("admDeptDAOImpl")
public class AdmDeptDAOImpl extends GenericHibernateDao implements IAdmDeptDAO {
	@Override
	public List<TbAdmDept> getAllDeptList() {
		List<TbAdmDept> list = this
				.find(" from TbAdmDept t order by t.serialno");
		return list;
	}

	@Override
	public List<TbAdmDept> getListByDeptname(String deptname) {
		List<TbAdmDept> list = this.find(" from TbAdmDept where deptname=?",
				deptname.trim());
		return list;
	}

	@Override
	public void addDept(TbAdmDept deptInfo) {
		this.create(deptInfo);
	}

	@Override
	public void deleteDept(String deptid) {
		this.bulkUpdate("delete from TbAdmDept t where t.deptid=?",new Object[]{deptid});
	}

	@Override
	public void updateDept(TbAdmDept deptInfo) {
		this.update(deptInfo);
	}

	@Override
	public TbAdmDept getDeptById(String deptid) {
		return (TbAdmDept) this.findById(new TbAdmDept(), deptid);
	}

	@Override
	public List<TbAdmDept> getDeptPageList(int rowStartIdx, int rowCount) {
		return this.findPaged("from TbAdmDept t order by t.serialno",
				rowStartIdx, rowCount);
	}

	@Override
	public long getDeptPageCount() {
		return this
				.findPagedConut("select count(*) from TbAdmDept t order by t.serialno");
	}
}